package com.aispeech.asr.apis.ssc.event;

import java.util.Map;

import org.springframework.context.ApplicationEvent;

import com.aispeech.asr.apis.ssc.data.domain.AudioInfo;
import com.aispeech.asr.apis.ssc.data.domain.SscResult;
import com.aispeech.asr.apis.ssc.data.domain.TaskDoc;
import com.aispeech.asr.apis.ssc.data.domain.PrepareAudioInfo;

public class SscEvent extends ApplicationEvent {
    private TaskDoc taskDoc;
    private AudioInfo audioInfo;
//    private SscResult sscResult;
//    private Map<String,PrepareAudioInfo> prepareAudioInfo;
    private volatile int retries = 0;

    public SscEvent(Object source, TaskDoc taskDoc) {
        super(source);
        this.taskDoc = taskDoc;
    }

    @Override
    public Object getSource() {
        return super.getSource();
    }

    public int getRetries() {
        return retries;
    }

    public boolean retryAgain(int limit) {
        boolean canRetry = (retries < limit);
        if (canRetry) {
            retries++;
        }

        return canRetry;
    }

    public TaskDoc getTaskDoc() {
        return taskDoc;
    }
    
    public AudioInfo getAudioInfo() {
        return audioInfo;
    }

    public void setAudioInfo(AudioInfo audioInfo) {
        this.audioInfo = audioInfo;
    }
    
//    public SscResult getSscResult() {
//        return sscResult;
//    }
//
//    public void setSscResult(SscResult sscResult) {
//        this.sscResult = sscResult;
//    }
//    
//    public Map<String,PrepareAudioInfo> getPrepareAudioInfo() {
//        return prepareAudioInfo;
//    }
//
//    public void setPrepareAudioInfo(Map<String,PrepareAudioInfo> prepareAudioInfo) {
//        this.prepareAudioInfo = prepareAudioInfo;
//    }
}
